<?php
class TemplateAdmin extends CI_Controller
{
	function home()
	{
		$data = array(
			'page'=>'homeadmin'
		);
		$this->load->view('admin/templateadmin', $data);
	}
	
	function index()
	{
		$this->load->view('admin/login');
	}
	
	function themdanhmuc()
	{
		$data = array(
					  'page'=>'themdanhmuc'
					  );
		$this->load->view('admin/templateadmin', $data);
	}
	
	function danhsachdanhmuc()
	{
		$data = array(
					  'dsdm'=>$this->mdanhmucsanpham->danhsachdanhmucAdmin(),
					  'page'=>'danhsachdanhmuc'
					  );
		$this->load->view('admin/templateadmin', $data);
	}
	
	
	function xulythem()
	{
		$tendm = $this->input->post('tendm');
		$hienthi = $this->input->post('hienthi') == 'true' ? 'true' : 'false';
		$this->mdanhmucsanpham->themdanhmuc($tendm, $hienthi);
		redirect('admin/templateadmin/danhsachdanhmuc');
	}
	
		function them()
	{
		$data = array(
					  'page'=>'themdanhmuc'
					  );
		$this->load->view('admin/templateadmin', $data);
	}
	
	function xoadanhmuc($madm)
	{
		$this->mdanhmucsanpham->xoadanhmuc($madm);
		redirect('admin/templateadmin/danhsachdanhmuc');
	}
	
		function capnhat($madm)
	{
		$data = array(
					  'ttdm'=>$this->mdanhmucsanpham->thongtindanhmuc($madm),
					  'page'=>'capnhatdanhmuc'
					  );
		$this->load->view('admin/templateadmin', $data);
	}
	
	function xulycapnhat()
	{
		$madm = $this->input->post('madm');
		$tendm = $this->input->post('tendm');
		$hienthi = $this->input->post('hienthi') == 'true' ? 'true' : 'false';
		$this->mdanhmucsanpham->capnhat($madm, $tendm, $hienthi);
		redirect('admin/templateadmin/danhsachdanhmuc');
	}
	
	function search()
	{
		$search = $this->input->post('search');
		$data = array(
					'dssp'=>$this->msanpham->searchsp($search),
					'page'=> 'searchsp'
				);
				$this->load->view('admin/templateadmin', $data);

	}
	
	function check()
	{
		$tk = $this->input->post('taikhoan');
		$mk = $this->input->post('matkhau');
		if($tk == 'admin' && $mk == 'admin')
		{
			redirect('admin/templateadmin/home');
		}
		else redirect('admin/templateadmin/');
	}
}

?>